package com.golxen.framework.user.player.condition;


import com.golxen.framework.event.condition.BaseCondition;
import com.golxen.framework.event.condition.ConditionModule;
import com.golxen.framework.event.condition.IUserConditionData;
import com.golxen.framework.event.condition.dao.entity.ConditionInfo;
import com.golxen.framework.event.condition.dao.entity.UserConditionData;
import com.golxen.framework.event.eGamePlayerEventType;
import com.golxen.framework.user.player.GamePlayer;

import java.math.BigInteger;

/**
 * 登陆天数
 */
public class LoginDaysCondition extends BaseCondition {

	public LoginDaysCondition(GamePlayer player, ConditionInfo conditionInfo, IUserConditionData userConditionData) {
		super(player,conditionInfo, userConditionData);
	}

	@Override
	public void addTrigger(GamePlayer player) {
		player.getModule(ConditionModule.class).getGamePlayerEvent().addListener(eGamePlayerEventType.LoginDays.getValue(), handle);
	}

	@Override
	public void removeTrigger(GamePlayer player) {
		player.getModule(ConditionModule.class).getGamePlayerEvent().removeListener(eGamePlayerEventType.LoginDays.getValue(), handle);
	}

	public boolean isCompleted(GamePlayer player) {
		return false;
	}


	@Override
	protected void changeValue(Object object) {
		int days = (int) object;
		UserConditionData data=(UserConditionData)userConditionData;
		data.setValue(data.getValue().add(BigInteger.valueOf(days)));
		userConditionData=data;
	}

}
